﻿using AiMoToServer.Entrance;

namespace AiMoWindows.Server
{
    static class ServerHelper
    {
        /// <summary>
        /// Aimo 社区
        /// </summary>
        public static string CommunityAddress => "https://aimo.zhai-zhai.com/#/";
        public static string CommunityShareAddress => "https://aimo.zhai-zhai.com/#/?share=";
        public static string EncodedPassword => ServerInfo.EncodedPassword;
        public static string UserName => ServerInfo.UserName;
        public static bool LogInAsCommunityUser => ServerInfo.LogInAsCommunityUser;
        public static bool HasNewVersion { get; private set; } = false;
        public static string NewVersion { get; private set; } = "";
        public static string CurrentAiMoVersion => Version.version;
        public static string RhinoVersion { get; private set; } = "";
        public static string MachineID => ServerInfo.MachineID;
        public static string WindowsUserName { get; } = Environment.UserName;

        public static void SetRhinoVersion(string version)
        {
            RhinoVersion = version;
            ServerInfo.SetRhinoVersion(version);
        }
        public static void ClearLogin()
        {
            ServerInfo.ClearLogin();
        }
        public static void SetInfoFromServer(string latestAiMoVersion, string attention)
        {
            NewVersion = latestAiMoVersion;
            HasNewVersion = NewVersion.CompareTo(CurrentAiMoVersion) > 0;
            Attentions.SetAttention(attention);
        }
        public static bool IsValidShareKey(string shareKey)
        {
            return ServerInfo.IsValidShareKey(shareKey);
        }
    }
}
